#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include<string.h>
#include<ctype.h>

int count_ele(char* p, int len,char ch)
{
    ch = toupper(ch);
    int count = 0;
    int i = 0;
    for (i = 0; i < len; i++)
    {
        if (p[i] == ch || p[i] == ch + 32)
            count++;
    }
    return count;
}
int main()
{
    char arr[1000] = { 0 };
    gets(arr);
    char ch = 0;
    scanf("%c", &ch);
    int len = strlen(arr);
    int ret = count_ele(arr, len,ch);
    printf("%d", ret);
}